﻿using Artizan.Iot.Hub.Mqtt.Server;
using MQTTnet.Server;
using Volo.Abp.DependencyInjection;

namespace Artizan.Iot.Hub.Mqtt.AspNetCore.Servser
{

    /// <summary>
    /// MQTTnet 集成 AspNetCore：
    /// https://github.com/dotnet/MQTTnet/wiki/Server#validating-mqtt-clients
    /// 
    /// 特别注意：这里使用的是单例接口 ISingletonDependency
    /// 
    /// ----------
    /// 使用MQTTnet部署MQTT服务:
    /// https://www.cnblogs.com/wx881208/p/14325011.html--+
    /// C# MQTTnet 3.1升级到MQTTnet 4.0 Client编程变化:
    /// https://blog.csdn.net/yuming/article/details/125834921?spm=1001.2101.3001.6650.7&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7-125834921-blog-127175694.pc_relevant_3mothn_strategy_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7-125834921-blog-127175694.pc_relevant_3mothn_strategy_recovery&utm_relevant_index=12
    /// </summary>
    public class IotHubMqttServer : IIotHubMqttServer, ISingletonDependency
    {
        private readonly IMqttServerService _mqttServerService;

        /// <summary>

        /// </summary>
        public MqttServer MqttServer { get; private set; }

        public IotHubMqttServer(IMqttServerService mqttServerService)
        {
            _mqttServerService = mqttServerService;
        }
        public void ConfigureMqttServer(MqttServer mqttServer)
        {
            MqttServer = mqttServer;
            _mqttServerService.ConfigureMqttService(mqttServer);
        }
    }
}
